package meta.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;

import java.util.Properties;

@Configurable
public class KaptchaConfig {

    @Bean
    public DefaultKaptcha captchaProducer(){
        DefaultKaptcha kaptcha = new DefaultKaptcha();
        kaptcha.setConfig(config());
        return kaptcha;
    }
    
    @Bean
    public Config config(){

        Properties properties = new Properties();
        properties.put("kaptcha.image.width",140);
                properties.put("kaptcha.image.height",40);
                properties.put("kaptcha.border","no");
                properties.put("kaptcha.textproducer.char.length",6);
                properties.put("kaptcha.textproducer.font.size",36);
                properties.put("kaptcha.textproducer.char.space",3);
                properties.put("kaptcha.textproducer.font.color","black");
                properties.put("kaptcha.noise.color","white");
                properties.put("kaptcha.obscurificator.impl","com.google.code.kaptcha.impl.WaterRipple");
                properties.put("kaptcha.textproducer.font.names","宋体,楷体,微软雅黑");
        return new Config(properties);
    }

}
